<?php

namespace app\admin\command;

use app\admin\command\Api\library\Builder;
use think\Config;
use think\console\Command;
use think\console\Input;
use think\console\input\Option;
use think\console\Output;
use think\Exception;

class Mysql extends Command
{
    protected function configure()
    {

        $this
            ->setName('mysql')
            ->setDescription('del mysql');
    }

    protected function execute(Input $input, Output $output)
    {
        $path = "/home/data";
        $data = scandir($path);
        sort($data);
        $max = 5;  //最大备份数量  $max - 2
        $num = count($data);
        $cha = $num - $max;
        if($cha>2){
            foreach($data as $file){
                if($file=='.' || $file=='..'){
                    continue;
                }
                if(file_exists($path.'/'.$file)){
                    unlink($path.'/'.$file);
                    $cha +=-1;
                }
                if($cha<1){
                    break;
                }
            }
        }
    }


}
